package guifiTest;

import java.util.ArrayList;

class PingThread extends Thread{
	IP host;
	int timeOut;
	
	public PingThread(IP ip, int t){
		host=ip;
		timeOut=t;
	}
	public void run(){
		host.checkReachable(timeOut);
	}
}


public class Tester{
	private ArrayList<IP> listOfIPs;
	int i;
	
	public Tester(){
		listOfIPs=new ArrayList<IP>();
	}
	
	public void addIP(String host){
		listOfIPs.add(new IP(host));
	}
	
	public ArrayList<IP> testAll() throws InterruptedException{
		PingThread threads[]=new PingThread[listOfIPs.size()];
		for(int i=0;i<listOfIPs.size();i++){
			threads[i]=new PingThread(listOfIPs.get(i),2000); //delay=1seg
			threads[i].start();
		}
		for(int i=0;i<listOfIPs.size();i++){
			threads[i].join();
		}
		return listOfIPs;
	}
}
